<%@ Page Language="C#" Debug="true" %>
<%@ import Namespace="System" %>
<%@ import Namespace="System.IO" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<%@ import Namespace="System.Data.Common" %>
<%@ import Namespace="System.Net" %>
<%@ import Namespace="System.Xml" %>
<%@ import Namespace="System.Xml.XPath" %>

<script runat="server">
    
void Page_Load() {
    try
    {
        String FileName = "TemplatePreview.sstext";
        String FilePath = Server.MapPath(FileName);

        if (File.Exists(FilePath))
        {
            //FileInfo fileInfo = new FileInfo(FileName);
            Response.Buffer = true;
            Response.Clear();

            Response.AddHeader("Content-Disposition", "attachment; filename=" + FileName);
            //Response.AddHeader("Content-Length", Convert.ToString(fileInfo.Length));
            Response.ContentType = "text/sstext";
            try
            {
                Response.WriteFile(FilePath);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message + " WriteFile Error");
            }
            //Response.Flush();
            //Response.End();
        }
    }
    catch (Exception ex)
    {
        String err = ex.Message;
        Response.Write(err + " main error");
    }
}
</script>